package common

type IStore[Q *I, I, D any] interface {
	Store(Q, uint8)
	Take(uint8) (Q, bool)
}

type Store[Q *I, I, D any] struct {
	data *D
	tier uint8
	cite Q
}

func NewStore[Q *I, I, D any](data D, cite Q, tier uint8) *Store[Q, I, D] {
	return &Store[Q, I, D]{data: &data, tier: tier, cite: cite}
}

func (s *Store[Q, I, D]) Store(data I, tier uint8) {
	s.tier = tier
	s.cite = &data
}

func (s *Store[Q, I, D]) Take(tier uint8) (Q, bool) {
	if s.tier == tier {
		return s.cite, true
	}
	return nil, false
}
